import type { IDeliveryTypeDTO, IRentMachineOrderInfoList } from "@/types/rentMachineManage/rentMachineOrderInfo";

/* 配送方式 */
function useDeliveryType(fn?: () => void) {
  const deliveryVisible = ref(false);
  const deliveryTypeForm = ref<IDeliveryTypeDTO>({
    id: 0,
    delivery_type: ""
  });

  /* 打开修改配送方式模态框 */
  function handleDeliveryType(row: IRentMachineOrderInfoList) {
    deliveryTypeForm.value.id = row.id;
    deliveryVisible.value = true;
  }

  /* 修改配送方式成功回调 */
  function handleDeliveryTypeSuccess() {
    deliveryVisible.value = false;
    if (fn) {
      fn();
    }
  }
  return {
    deliveryVisible,
    deliveryTypeForm,
    handleDeliveryType,
    handleDeliveryTypeSuccess
  };
}

export default useDeliveryType;
